<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

        <title>T-html5</title>
        <meta name="description" content="">
        <meta name="author" content="jurnlee">

        <meta name="viewport" content="width=device-width; initial-scale=1.0">

        <link rel="shortcut icon" href="/favicon.ico">
        <link rel="apple-touch-icon" href="/apple-touch-icon.png">
        <script src="vendor/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"> </script>
        <style type="text/css">
            *{
                margin:0;
                padding:0;
            }
            .main{
            	position: relative;
            	width: 80%;
            	height: 200px;
            	border: thin solid #CCCCCC;
            	border-radius: 3px;
            	padding: 20px;
            	margin: 10px auto;
            }
        </style>
        <script type="text/javascript">
            
            $(function(){
                $("#getsth").click(function(){
                	$.ajax({
                	type:"get", //这里是从服务器拉取数据，不能用post
                	url:"remote.txt",
                	complete:function(xhr,txt){
                		alert(xhr.status+"---"+txt);
                		if(xhr.status==200){
                			var resp = ""+xhr.responseText;
                			var jsonval = eval('(' + resp + ')'); 
                			$("#txt").append(resp+"  ----  "+jsonval.resultCode);
                			if(jsonval.resultCode==0){
                				//...
                			}else{
                				alert("操作失败！"+jsonval.resultMsg+"， 代码是："+jsonval.resultCode);
                			}
                			
                		}else{
                			alert("服务器错误！");
                		}
                	}
                });
                })
                
            });
        </script>
    </head>

    <body>
        <div>
            <header>
                <h1>T-html5</h1>
            </header>
            <nav>
                <p><a href="/">Home</a></p>
                <p><a href="/contact">Contact</a></p>
            </nav>

            <div class="main">
				<button id="getsth">-getSth-</button>
				<div id="txt"></div>
            </div>

            <footer>
                <p>
                    &copy; Copyright  by jurnlee
                </p>
            </footer>
        </div>
    </body>
</html>
